<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class mp extends My_Controller {
	
	function __construct(){
		parent::__construct();
		//$this->load->library('excel');
		$this->load->model('mdl_mp');
	}
	
	public function index()
	{
		//$this->open();
		
		# config pagination
		$thn=$this->session->userdata("thnanggaran");
		$config['base_url'] = base_url().'/'.$this->config->item('index_page').'/mp/index/';
		//$query = $this->db->get_where('tbl_mp');
		$query = $this->db->get_where('mp_tbl_mp', array('TahunAnggaran' => $thn));
		$config['total_rows'] = $query->num_rows();
		//$config['total_rows'] = $this->db->count_all('tbl_rpijm');
		$config['per_page'] = '10';
		$config['num_links'] = '3';

		$this->pagination->initialize($config);	
		
		$data['result'] = $this->mdl_mp->getData($config['per_page'], $this->uri->segment(3));
		$this->load->view('mp/mp_list', $data);
		
		
		//$this->close();
	}
    
	
       	
	public function edit($id){
		//$this->open();
		
		
		$data['result'] = $this->mdl_mp->getDataEdit($id);
		$this->load->view('mp/mp_edit', $data);
		
		//$this->close();
	}
	
	public function proses_edit(){
		//$this->open();
		
		$data['id'] = $this->input->post('id');
		/*$data['TglCreate'] = $this->input->post('TglCreate');
		$data['kd_akun'] = $this->input->post('kd_akun');
		$data['kd_wilayah'] = $this->input->post('kd_wilayah');
		$data['uraian'] = $this->input->post('uraian');
		$data['detailLokasi'] = $this->input->post('detailLokasi');
		*/
		$data['Prioritas'] = $this->input->post('Prioritas');
		
		
			$this->mdl_mp->update($data);
			redirect('mp');
		
		
		//$this->close();
	}
	
	public function proses_delete($id){
		if($this->mdl_mp->delete($id)){
			redirect('mp');
		}else{
			// code u/ gagal simpan
		}
	}
	
	
}
?>